#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string s1, s2;
	cin >> s1 >> s2;
	int ans1 = 1;
	int ans2 = 1;
	for (int i = 0; i < s1.size(); i++)
		ans1 *= (s1[i] - 'A' + 1) % 47;
	for (int i = 0; i < s2.size(); i++)
		ans2 *= (s2[i] - 'A' + 1) % 47;
	if (ans1 % 47 == ans2 % 47)
		cout << "GO";
	else
		cout << "STAY";
	return 0;
}
